package hello.service;

import org.apache.kafka.clients.producer.Producer;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaOperations;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.support.ProducerListener;
import org.springframework.stereotype.Component;

/**
 * Created by JingjingMa on 2017/05/26.
 *
 * @Email <a href="majinding888@163.com">majinding888@foxmail.com</a>
 */
@Component
public class MyMsgProducer {

    private Logger log = LoggerFactory.getLogger(MyMsgProducer.class);

    @Autowired
    private KafkaTemplate<String, String> kafkaTemplate;

    public void send(String topic, String msg) {
        kafkaTemplate.send(topic, msg);
        log.info("MsgProducer>>>{}:{}", topic, msg);
    }
}
